﻿using Sasa.QualityTools.CodeAnalysis.Core.VisualStudio;

namespace Sasa.QualityTools.CodeAnalysis.FxCopIntegrator.VisualStudio
{
    public class ProjectItem : IProjectItem
    {
        private EnvDTE.ProjectItem item;


        public string Name
        {
            get
            {
                return item.Name;
            }
        }

        public ProjectItemKind Kind
        {
            get
            {
                switch (item.Kind)
                {
                    case EnvDTE.Constants.vsProjectItemKindPhysicalFolder:
                        return ProjectItemKind.Directory;
                    default:
                        return ProjectItemKind.Unknown;
                }
            }
        }

        public ICodeModel CodeModel
        {
            get
            {
                return VisualStudio.CodeModel.CreateInstance(item.FileCodeModel);
            }
        }

        public IProject ContainingProject
        {
            get
            {
                return Project.CreateInstance(item.ContainingProject);
            }
        }


        public ProjectItem(EnvDTE.ProjectItem item)
        {
            this.item = item;
        }


        public void AddFromFile(string path)
        {
            item.ProjectItems.AddFromFile(path);
        }
    }
}
